#ifndef part2_vector_h
#define part2_vector_h

#include <glog/logging.h>

#define DEFAULT_CAPACITY  50

template <typename T>
class  Vector_own{

public:
    Vector_own(int capacity=DEFAULT_CAPACITY, int size=0, T value = 0);
    ~Vector_own();
    inline int getCapacity(){ return _capacity;}
    inline int getSize(){return _size;}
    T operator[](int i);
protected:
    void copyFrom(T const *A, int lo, int hi);

private:
    int _size;
    int _capacity;
    T* _elem;
};

template <typename T>
Vector_own<T>::Vector_own(int capacity, int size, T value)
{
    _capacity = capacity;
    _elem = new T[_capacity];   //这里不用再定义_elem，因为在类里面已经定义过了，直接用就可以了。类内部的数据
    _size = size;

    for(_size = 0; _size < size; _size++)
    {
        _elem[_size] = value + _size;
    }
}

template <typename T>
Vector_own<T>::~Vector_own()
{
    delete _elem;
}

template<typename T>
T Vector_own<T>::operator[](int i)
{
  T tempValue;
  tempValue = *(_elem + sizeof(T)*i);
  return tempValue;
}

#endif
